package com.dant.effects
{
	import mx.core.ClassFactory;
	import mx.effects.IEffectInstance;
	import mx.effects.TweenEffect;
	import mx.effects.effectClasses.FadeInstance;

	public class CloseAdvancedPanelEffect extends TweenEffect
	{
		/**
		 *  @private
		 */
		private static var AFFECTED_PROPERTIES:Array =
		[
			"alpha"
		];
		
	    [Inspectable(category="General", defaultValue="undefined")]
	    
	    /** 
	     *  Initial transparency level between 0.0 and 1.0, 
	     *  where 0.0 means transparent and 1.0 means fully opaque. 
	     * 
	     *  <p>If the effect causes the target component to disappear,
	     *  the default value is the current value of the target's
	     *  <code>alpha</code> property.
	     *  If the effect causes the target component to appear,
	     *  the default value is 0.0.</p>
	     */
	    public var alphaFrom:Number;
	    

	    [Inspectable(category="General", defaultValue="NaN")]
	    
	    /** 
	     *  Final transparency level,
	     *  where 0.0 means transparent and 1.0 means fully opaque.
	     *
	     *  <p>If the effect causes the target component to disappear,
	     *  the default value is 0.0.
	     *  If the effect causes the target component to appear,
	     *  the default value is the current value of the target's
	     *  <code>alpha</code> property.</p>
	     */
	    public var alphaTo:Number;


		public function CloseAdvancedPanelEffect(target:Object=null)
		{
			super(target);
			instanceClass = FadeInstance;
		}

	//--------------------------------------------------------------------------
	//
	//  Overridden methods
	//
	//--------------------------------------------------------------------------
 
		/**
		 *  @private
		 */
		override public function getAffectedProperties():Array /* of String */
		{
			return AFFECTED_PROPERTIES;
		}	

		/**
		 *  @private
		 */
		override protected function initInstance(instance:IEffectInstance):void
		{
			super.initInstance(instance);

			var fadeInstance:FadeInstance = FadeInstance(instance);

			if (!isNaN(alphaFrom))
			{
				fadeInstance.alphaFrom = alphaFrom;
			}
			else
			{
				fadeInstance.alphaFrom = 1;
			}
			if (!isNaN(alphaTo))
			{
				fadeInstance.alphaTo = alphaTo;
			}
			else
			{
				fadeInstance.alphaTo = 0;
			}
		}
	}
}